// pages/orderDetail/orderDetail.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        address:{},
        createTime:'',
        receiver:'',
        phone:'',
        nums:'',
        sumPrice:'',
        orderNumber:'',
        logisticsNumber:'',
        isGetType:'',
        menuList:[],
        logisticsTime:'',
        decNum:0,
        expressCode:''
    },
    nextShopping(){
        wx.switchTab({
          url: '/pages/index/index',
        })
    },
    express(e){
        if(!this.data.expressCode){
            wx.showModal({
                content: '商家还未发货，请耐心等待',
                showCancel:false,
              })
        } else {
            wx.get('http://localhost:8000/wx/express?shipperCode='+this.data.expressCode+'&logisticCode='+this.data.logisticsNumber).then(res => {
                wx.navigateTo({
                    url: '/pages/express/express?expressCode=' + e.currentTarget.dataset.expresscode +"&logisticsNumber="+ e.currentTarget.dataset.logisticsnumber
                })
      })
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var shopping = JSON.parse(options.item)
        console.log('option',shopping)
        let time = shopping.logisticsTime
        let date = new Date(time)
        let times=date.getFullYear() + '-' + ((date.getMonth() + 1)<10?"0"+(date.getMonth() + 1):(date.getMonth() + 1) )+ '-' + (date.getDate()<10?"0"+date.getDate():date.getDate() ) +' '+ (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':' +(date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes())
        shopping.logisticsTime = times
        this.setData({
            address:shopping.city.toString() + shopping.area.toString(),
            createTime:shopping.createTime,
            nums:shopping.nums,
            phone:shopping.phone,
            receiver:shopping.receiver,
            orderNumber:shopping.orderNumber,
            logisticsNumber:shopping.logisticsNumber,
            isGetType:shopping.isGetType,
            menuList:shopping.list,
            sumPrice:shopping.sumPrice,
            logisticsTime:shopping.logisticsTime,
            decNum:shopping.decNum,
            expressCode:shopping.expressCode
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})